package com.asset.dispoal.business.appoint;

import com.asset.dispoal.business.appoint.api.AppointService;
import com.asset.dispoal.business.appoint.dto.AppointDetailResponse;
import com.asset.dispoal.business.appoint.dto.AppointDownloadOrderRequest;
import com.asset.dispoal.business.appoint.dto.AppointInsertRequest;
import com.asset.dispoal.business.appoint.dto.AppointPageRequest;
import com.asset.dispoal.business.appoint.dto.AppointPageResponse;
import com.asset.dispoal.business.appoint.dto.CanAppointCaseRequest;
import com.asset.dispoal.business.appoint.dto.CanAppointCaseResponse;
import com.asset.dispoal.business.appoint.dto.QueryAppointCaseRequest;
import com.asset.dispoal.business.appoint.dto.QueryDropAppointRequest;
import com.asset.dispoal.business.appoint.dto.QueryWithdrawlPageRequest;
import com.asset.dispoal.business.appoint.dto.QueryWithdrawlPageResponse;
import com.asset.dispoal.business.bsCase.dto.BsCaseResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import tech.mhuang.pacebox.springboot.core.permission.annotation.Permission;
import tech.mhuang.pacebox.springboot.protocol.Result;
import tech.mhuang.pacebox.springboot.protocol.data.PageVO;

import java.util.List;

/**
 * @author qr
 * @date 2022/5/17$
 */
@RestController
@RequestMapping("business/appoint")
@Api(value = "委派管理", tags = "委派管理")
public class AppointController {

    @Autowired
    AppointService appointService;


    @Permission(code = "caseManageDelegate:query", param = "appoint.create_user")
    @GetMapping("queryPage")
    @ApiOperation(value = "委派管理分页查询", notes = "委派管理分页查询")
    public Result<PageVO<AppointPageResponse>> queryPage(AppointPageRequest request) {
        return appointService.queryPage(request);
    }

    @GetMapping("getById")
    @ApiOperation(value = "委派管理明细", notes = "委派管理明细")
    public Result<AppointDetailResponse> getById(String id) {
        return appointService.getById(id);
    }

    @GetMapping("queryDetailByAppointId")
    @ApiOperation(value = "委派管理案件查询", notes = "委派管理案件查询")
    public Result<List<BsCaseResponse>> queryDetailByAppointId(QueryAppointCaseRequest request) {
        return appointService.queryDetailByAppointId(request);
    }

    @GetMapping(value = "/queryPageCanAppointCase")
    @ApiOperation(value = "查询可以委派的案件", notes = "查询可以委派的案件")
    public Result<PageVO<CanAppointCaseResponse>> queryPageCanAppointCase(CanAppointCaseRequest request) {
        return appointService.queryPageCanAppointCase(request);
    }

    //    @Permission(code = "caseManageFlaw:query", param = "appoint_mapper.withdrawal_user_id")
    @GetMapping(value = "/queryPageWithdrawal")
    @ApiOperation(value = "瑕疵池和退案池分页查询", notes = "瑕疵池和退案池分页查询")
    public Result<PageVO<QueryWithdrawlPageResponse>> queryPageWithdrawal(QueryWithdrawlPageRequest request) {
        return appointService.queryPageWithdrawal(request);
    }


    @PostMapping(value = "/insertAppoint")
    @ApiOperation(value = "派案及退案委派", notes = "派案及退案委派")
    public Result insertAppoint(@RequestBody AppointInsertRequest request) {
        return appointService.insertAppoint(request);
    }

    @Permission(code = "caseManageDelegate:particular", param = "mapper.operate_user")
    @GetMapping(value = "/queryDropAppoint")
    @ApiOperation(value = "查询退案的批次", notes = "查询退案的批次")
    public Result<List<AppointPageResponse>> queryDropAppoint(QueryDropAppointRequest request) {
        return appointService.queryDropAppoint(request);
    }

    @GetMapping(value = "/queryAppoint")
    @ApiOperation(value = "查询委派的批次", notes = "查询委派的批次")
    public Result<List<AppointPageResponse>> queryAppoint(QueryDropAppointRequest request) {
        return appointService.queryAppoint(request);
    }

    @PostMapping(value = "/downloadOrder")
    @ApiOperation(value = "下单", notes = "下单")
    public Result downloadOrder(AppointDownloadOrderRequest request) {
        return appointService.downloadOrder(request);
    }
}
